package com.maiji.cloud.service.impl;

import com.maiji.cloud.entities.login.UploadRecord;
import com.maiji.cloud.mapper.UploadRecordMapper;
import com.maiji.cloud.request.BaseInputDto;
import com.maiji.cloud.request.SaveURBelongIdReqDto;
import com.maiji.cloud.response.BaseDataResDto;
import com.maiji.cloud.response.Status;
import com.maiji.cloud.service.UploadRecordService;
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.ArrayList;
import java.util.List;

@Service
@Transactional
public class UploadRecordServiceImpl extends ServiceImpl<UploadRecordMapper, UploadRecord> implements UploadRecordService {

    public BaseDataResDto<Boolean> saveBelongId(BaseInputDto<ArrayList<SaveURBelongIdReqDto>> inputDto){

        ArrayList<SaveURBelongIdReqDto> arrayList = inputDto.getData();
        BaseDataResDto<Boolean> resDto = new BaseDataResDto();

        Integer code = this.baseMapper.updateBelongIdWithImages(arrayList);

        resDto.setStatus( Status.SUCCESS );

        resDto.setData(true);

        return resDto;
    }

	@Override
	public List<UploadRecord> getUploudImgs(String id,boolean isMain) {
		if(isMain == true) {
			return baseMapper.selectMainListByBelongId(id,isMain);	
		}
		return baseMapper.selectListByBelongId(id);
	}
}
